package NovoSISAM.Gui;

import java.awt.*;
import javax.swing.*;

/**
 *
 * @author Cleiviane
 */
public class TelaPrincipal extends javax.swing.JFrame {

    private static boolean logado = true;

    /** Creates new form TelaPrincipal */
    public TelaPrincipal() {
        initComponents();
        this.setExtendedState(MAXIMIZED_BOTH);
    }

    /**
     * @return the logado
     */
    public static boolean isLogado() {
        return logado;
    }

    /**
     * @param aLogado the logado to set
     */
    public static void setLogado(boolean aLogado) {
        logado = aLogado;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        desktop = new javax.swing.JDesktopPane();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPane1 = new javax.swing.JTextPane();
        jLabel2 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        MenuPacientes = new javax.swing.JMenuItem();
        MenuMedicos = new javax.swing.JMenuItem();
        MenuMedicamentos = new javax.swing.JMenuItem();
        MenuParceiros = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        MenuUsuarios = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        MenuConsultas = new javax.swing.JMenuItem();
        MenuAgendamento = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        MenuRelatorios = new javax.swing.JMenuItem();
        JMenuSobre = new javax.swing.JMenu();
        MenuSobre = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        desktop.setBackground(new java.awt.Color(0, 152, 153));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/NovoSISAM/Gui/Imagens/CyberSystem-Logo2.jpg"))); // NOI18N
        jLabel1.setBounds(420, 230, 440, 340);
        desktop.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel4.setFont(new java.awt.Font("Ravie", 1, 42)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(0, 51, 255));
        jLabel4.setText("    Sistema de Apoio a Cliníca Médica");
        jLabel4.setBounds(30, 10, 1110, 130);
        desktop.add(jLabel4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jScrollPane1.setViewportView(jTextPane1);

        jScrollPane1.setBounds(30, 0, 1310, 160);
        desktop.add(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel2.setFont(new java.awt.Font("Ravie", 0, 36)); // NOI18N
        jLabel2.setText("SISAM");
        jLabel2.setBounds(580, 560, 330, 140);
        desktop.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jMenu1.setText("Cadastros");

        MenuPacientes.setText("Pacientes");
        MenuPacientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuPacientesActionPerformed(evt);
            }
        });
        jMenu1.add(MenuPacientes);

        MenuMedicos.setText("Medicos");
        MenuMedicos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuMedicosActionPerformed(evt);
            }
        });
        jMenu1.add(MenuMedicos);

        MenuMedicamentos.setText("Medicamentos");
        MenuMedicamentos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuMedicamentosActionPerformed(evt);
            }
        });
        jMenu1.add(MenuMedicamentos);

        MenuParceiros.setText("Parceiros");
        MenuParceiros.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuParceirosActionPerformed(evt);
            }
        });
        jMenu1.add(MenuParceiros);

        jMenuItem2.setText("Funcionarios");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);

        MenuUsuarios.setText("Usuarios");
        MenuUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuUsuariosActionPerformed(evt);
            }
        });
        jMenu1.add(MenuUsuarios);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Consultas");

        MenuConsultas.setText("Consultas");
        MenuConsultas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuConsultasActionPerformed(evt);
            }
        });
        jMenu2.add(MenuConsultas);

        MenuAgendamento.setText("Agendamento");
        MenuAgendamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuAgendamentoActionPerformed(evt);
            }
        });
        jMenu2.add(MenuAgendamento);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Relatórios");

        MenuRelatorios.setText("Relatórios");
        MenuRelatorios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuRelatoriosActionPerformed(evt);
            }
        });
        jMenu3.add(MenuRelatorios);

        jMenuBar1.add(jMenu3);

        JMenuSobre.setText("Sobre");
        JMenuSobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JMenuSobreActionPerformed(evt);
            }
        });

        MenuSobre.setText("Sobre");
        JMenuSobre.add(MenuSobre);

        jMenuBar1.add(JMenuSobre);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktop, javax.swing.GroupLayout.DEFAULT_SIZE, 1345, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(desktop, javax.swing.GroupLayout.PREFERRED_SIZE, 759, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void MenuPacientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuPacientesActionPerformed
        if (isLogado()) {
            Cadastro_Pacientes telaPac = new Cadastro_Pacientes();
            desktop.add(telaPac);
            centralizaTela(telaPac);
            telaPac.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(this, "Você ainda não está logado!");
        }        // TODO add your handling code here:
    }//GEN-LAST:event_MenuPacientesActionPerformed

    private void MenuMedicosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuMedicosActionPerformed
        if (isLogado()) {
            Cadastro_Medicos telaMed = new Cadastro_Medicos();
            desktop.add(telaMed);
            centralizaTela(telaMed);
            telaMed.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(this, "Você ainda não está logado!");
        }

    }//GEN-LAST:event_MenuMedicosActionPerformed

    private void MenuMedicamentosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuMedicamentosActionPerformed
        if (isLogado()) {
            Cadastro_Medicamentos telaMedic = new Cadastro_Medicamentos();
            desktop.add(telaMedic);
            centralizaTela(telaMedic);
            telaMedic.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(this, "Você ainda não está logado!");
        }
    }//GEN-LAST:event_MenuMedicamentosActionPerformed

    private void MenuParceirosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuParceirosActionPerformed
        if (isLogado()) {
            Cadastro_Parceiros telaParc = new Cadastro_Parceiros();
            desktop.add(telaParc);
            centralizaTela(telaParc);
            telaParc.setVisible(true);
        } else {
            JOptionPane.showMessageDialog(this, "Você ainda não está logado!");
        }
    }//GEN-LAST:event_MenuParceirosActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        if (isLogado()) {
                Cadastro_Funcionarios telaFunc = new Cadastro_Funcionarios();
                desktop.add(telaFunc);
                centralizaTela(telaFunc);
                telaFunc.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(this, "Você ainda não está logado!");
            }
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void MenuUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuUsuariosActionPerformed
        if (isLogado()) {
                Cadastro_Usuario telaUsuario = new Cadastro_Usuario();
                desktop.add(telaUsuario);
                centralizaTela(telaUsuario);
                telaUsuario.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(this, "Você ainda não está logado!");
            }
    }//GEN-LAST:event_MenuUsuariosActionPerformed

    private void MenuConsultasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuConsultasActionPerformed
        if (isLogado()) {
                Consulta_Medica telaConsulta = new Consulta_Medica();
                desktop.add(telaConsulta);
                centralizaTela(telaConsulta);
                telaConsulta.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(this, "Você ainda não está logado!");
            }
    }//GEN-LAST:event_MenuConsultasActionPerformed

    private void MenuRelatoriosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuRelatoriosActionPerformed
        if (isLogado()) {
                Relatorios telaRelat = new Relatorios();
                desktop.add(telaRelat);
                centralizaTela(telaRelat);
                telaRelat.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(this, "Você ainda não está logado!");
            }
    }//GEN-LAST:event_MenuRelatoriosActionPerformed

    private void JMenuSobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JMenuSobreActionPerformed
        //TelaSobre sobre = new TelaSobre();
            Sobre sobre = new Sobre(this, logado);
            sobre.setLocationRelativeTo(TelaPrincipal.this);
            sobre.setVisible(true);
    }//GEN-LAST:event_JMenuSobreActionPerformed

    private void MenuAgendamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuAgendamentoActionPerformed
        if (isLogado()) {
                Cadastro_Agendamentos telaAgend = new Cadastro_Agendamentos();
                desktop.add(telaAgend);
                centralizaTela(telaAgend);
                telaAgend.setVisible(true);
            } else {
                JOptionPane.showMessageDialog(this, "Você ainda não está logado!");
            }
    }//GEN-LAST:event_MenuAgendamentoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new TelaPrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu JMenuSobre;
    private javax.swing.JMenuItem MenuAgendamento;
    private javax.swing.JMenuItem MenuConsultas;
    private javax.swing.JMenuItem MenuMedicamentos;
    private javax.swing.JMenuItem MenuMedicos;
    private javax.swing.JMenuItem MenuPacientes;
    private javax.swing.JMenuItem MenuParceiros;
    private javax.swing.JMenuItem MenuRelatorios;
    private javax.swing.JMenuItem MenuSobre;
    private javax.swing.JMenuItem MenuUsuarios;
    private javax.swing.JDesktopPane desktop;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextPane jTextPane1;
    // End of variables declaration//GEN-END:variables

    public static void centralizaTela(JInternalFrame fr) {

        Dimension d = fr.getDesktopPane().getSize();
        fr.setLocation((d.width - fr.getSize().width) / 2, (d.height - fr.getSize().height) / 2);
    }
}
